package file;

import java.io.File;

import static file.FileDemo3.*;

//键盘接收文件夹路径
public class FileDemo8 {
    public static void main(String[] args) {
        File dir= getDir();
        System.out.println(getlength(dir));
    }

    public static long getlength(File dir) {
        long sum=0;
        File[] files = dir.listFiles();
        for (File file : files) {
            if(file.isFile()){
                sum+=file.length();
            }else {
                if (file.listFiles() != null) {
                    sum+=getlength(file);
                }
            }
        }
        return sum;
    }
}
